#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	freopen( "candy.in"  , "r" , stdin );
	freopen( "candy.out" , "w" , stdout );
	int n , l , r , ans = 0;
	cin >> n >> l >> r;
	if ( r - l >= n ) ans = n - 1; 
	else{
		r -= n , l -= n;
		for ( int i = l ; i <= r ; i ++ ){
			ans = max( ans , i % n );
		}
	}
	cout << ans << endl;
	return 0;
}
